package cn.befory.controller;

import cn.befory.service.LoginService;
import cn.befory.tools.ResponseContent;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by befory on 2019/8/19.
 */
@Controller
public class LoginController {
    @Autowired
    LoginService loginService;

//    @GetMapping("/login")
//    public ModelAndView toLogin(){
//        ModelAndView mv =  new ModelAndView();
//        mv.setViewName("login");
//        return mv;
//    }
//
//    @GetMapping("/")
//    public ModelAndView root(){
//        return toLogin();
//    }
//
//    @GetMapping("/index")
//    public ModelAndView toIndex(){
//        ModelAndView mv =  new ModelAndView();
//        mv.setViewName("index");
//        return mv;
//    }
//
//    @GetMapping("/index_v1")
//    public ModelAndView toIndexV1(){
//        ModelAndView mv =  new ModelAndView();
//        mv.setViewName("index_v1");
//        return mv;
//    }


    @PostMapping("/signIn")
    public ResponseEntity login(@RequestParam String loginName,
                                @RequestParam String password) throws Exception {
        return ResponseEntity.ok(ResponseContent.success(loginService.login(loginName, password)));
    }
}
